package lib

func init() {
	Probs = append(Probs, Problem{
		Num:         231,
		Discription: "判断是否为2的幂",
		Level:       1,
		Labels: map[string]int{
			"位运算": 1,
		},
	})
}

func IsPowerOfTwo(n int) bool {
	//<=0不用判断
	for n <= 0 {
		return false
	}

	for n != 0 {
		//最后一位位1且整体不为1的话就不是
		if n&1 == 1 && n != 1 {
			return false
		}

		n >>= 1
	}

	return true
}
